package day13.tarena.com;
import java.util.*;
public class TestIterator {
	public static void main(String[] args) {
		Set set = new HashSet();
		set.add("1");
		set.add("2");
		set.add("3");
		set.add("4");
		set.add("5");
		System.out.println(set);  
		Iterator it = set.iterator();  //迭代器的创建在循环外面。
		while(it.hasNext()){
				Object obj = it.next();
				if(obj instanceof String){
					String s = (String)obj;
					if("3".equals(s)){
						it.remove();
						System.out.println(s);
					}
					
				}
		}
		
		for(Object obj : set){
				System.out.println(obj);
		}
	}
}
